Merge "tests: Allow string to be passed to getTestUser() etc."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 4 Oct 2018 15:54:57 +0000 (15:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 4 Oct 2018 15:54:57 +0000 (15:54 +0000)
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/TestUserRegistry.php

index d675e85..dd85cc2 100644 (file)
@@ -158,7 +158,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
         *
         * @since 1.28
         *
-        * @param string[] $groups Groups the test user should be in.
+        * @param string|string[] $groups Groups the test user should be in.
         * @return TestUser
         */
        public static function getTestUser( $groups = [] ) {
@@ -170,7 +170,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
         *
         * @since 1.28
         *
-        * @param string[] $groups Groups the test user should be added in.
+        * @param string|string[] $groups Groups the test user should be added in.
         * @return TestUser
         */
        public static function getMutableTestUser( $groups = [] ) {
index 24aee24..3064a3d 100644 (file)
@@ -28,7 +28,7 @@ class TestUserRegistry {
         *
         * @param string $testName Caller's __CLASS__. Used to generate the
         *  user's username.
-        * @param string[] $groups Groups the test user should be added to.
+        * @param string|string[] $groups Groups the test user should be added to.
         * @return TestUser
         */
        public static function getMutableTestUser( $testName, $groups = [] ) {
@@ -38,7 +38,7 @@ class TestUserRegistry {
                        "TestUser $testName $id",  // username
                        "Name $id",                // real name
                        "$id@mediawiki.test",      // e-mail
-                       $groups,                   // groups
+                       (array)$groups,            // groups
                        $password                  // password
                );
                $testUser->getUser()->clearInstanceCache();
@@ -54,11 +54,11 @@ class TestUserRegistry {
         *
         * @since 1.28
         *
-        * @param string[] $groups Groups the test user should be added to.
+        * @param string|string[] $groups Groups the test user should be added to.
         * @return TestUser
         */
        public static function getImmutableTestUser( $groups = [] ) {
-               $groups = array_unique( $groups );
+               $groups = array_unique( (array)$groups );
                sort( $groups );
                $key = implode( ',', $groups );